package comm

import (
	"golang.org/x/crypto/bcrypt"
)

// BCrypt 加密
func BCrypt(input string) string {
	password, err := bcrypt.GenerateFromPassword([]byte(input), bcrypt.DefaultCost)

	if err != nil {
		return input
	}
	return string(password)
}

func BcryptVerify(input string, hash string) bool {
	err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(input))
	return err == nil
}
